home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Development Tools & Languages / Dylan Related / Mindy-1.1 (sources only) / mindy-1.1 / libraries / dylan / string.dylan < prev    next >
Encoding:
Text File  |  1994-06-28  |  2.4 KB  |  76 lines  |  [TEXT/ttxt]

  1. module: Dylan
  2. rcs-header: $Header: string.dylan,v 1.5 94/06/27 17:10:38 wlott Exp $
  3.  
  4. //======================================================================
  5. //
  6. // Copyright (c) 1994  Carnegie Mellon University
  7. // All rights reserved.
  8. // 
  9. // Use and copying of this software and preparation of derivative
  10. // works based on this software are permitted, including commercial
  11. // use, provided that the following conditions are observed:
  12. // 
  13. // 1. This copyright notice must be retained in full on any copies
  14. //    and on appropriate parts of any derivative works.
  15. // 2. Documentation (paper or online) accompanying any system that
  16. //    incorporates this software, or any part of it, must acknowledge
  17. //    the contribution of the Gwydion Project at Carnegie Mellon
  18. //    University.
  19. // 
  20. // This software is made available "as is".  Neither the authors nor
  21. // Carnegie Mellon University make any warranty about the software,
  22. // its performance, or its conformity to any specification.
  23. // 
  24. // Bug reports, questions, comments, and suggestions should be sent by
  25. // E-mail to the Internet address "gwydion-bugs@cs.cmu.edu".
  26. //
  27. //======================================================================
  28. //
  29. //  This file contains the support for strings that isn't built in.
  30. //
  31.  
  32. define method as (clas == <string>, collection :: <collection>)
  33.   as(<byte-string>, collection)
  34. end as;
  35.  
  36. define method \< (string1 :: <string>, string2 :: <string>)
  37.   block (return)
  38.     let (init, limit, next, done?, key, elem) =
  39.        forward-iteration-protocol(string2);
  40.     for (char1 in string1,
  41.      state = init then next(string2, state),
  42.      until done?(string2, state, limit))
  43.       let char2 = elem(string2, state);
  44.       case
  45.     char1 < char2 => return(#t);
  46.     char1 > char2 => return(#f);
  47.      otherwise => #f;
  48.       end case
  49.     finally
  50.       if (done?(string2, state, limit)) #f else #t end
  51.     end for
  52.   end block
  53. end \<;
  54.  
  55. define method as-lowercase (string :: <string>)
  56.   map(as-lowercase, string)
  57. end as-lowercase;
  58.  
  59. define method as-uppercase (string :: <string>)
  60.   map(as-uppercase, string)
  61. end as-uppercase;
  62.  
  63. define method as-lowercase! (string :: <string>)
  64.   map-into(string, as-lowercase, string)
  65. end as-lowercase!;
  66.  
  67. define method as-uppercase! (string :: <string>)
  68.   map-into(string, as-uppercase, string)
  69. end as-uppercase!;
  70.  
  71.  
  72.  
  73. define method element-setter (new, string :: <byte-string>, index :: <integer>)
  74.   error(make(<type-error>, value: new, type: <character>));
  75. end;
  76.